import Vue from 'vue';
// 引入路由器
import VueRouter from 'vue-router';
// 引入路由组件
import About from '../views/About.vue';
import Home from '../views/Home.vue';
import HomeA from '../views/HomeA.vue';
import HomeB from '../views/HomeB.vue';
import First from '../views/First.vue';
import Second from '../views/Second.vue';
import Third from '../views/Third.vue'

// 声明使用插件
Vue.use(VueRouter);
export default new VueRouter({
    mode: "history",
    // 注册路由
    routes: [{
        path: '/about', //  /代表根路径 路径中不要出现大写字符
        name: 'about',
        alias: "/aboutalias", //别名   属性值为路径
        component: About
    }, {
        path: '/home/:id', //params传值方式
        name: 'home',
        // component: Home,
        components: {
            default: Home,
            First: First,
            Second,
            Third
        },
        children: [{
            path: '/home/homea', //对于二级路由  注意路径问题 写上前面所有的父级路径 ,如果不写父级的路径，就直接写子级路由的路径，但是千万别加 /
            component: HomeA

        }, {
            path: 'homeb',
            component: HomeB
        }]
    }, {
        /* 打开页面默认显示某个组件，称为路由重定向 */
        path: '/',
        redirect: '/about' //写路径也可以写路由名称
        /*  redirect: {
             name: 'about'
         } */
    }]
})